#pragma once

#include <QString>
#include <QObject>

#include "../data/datainterface.h"
#include "../math/boundingbox.h"

class QWidget;

namespace PBVP {
	class RenderPlugin;
	/// Base component of the data manager
	class DataNode : public QObject {
		Q_OBJECT
	
	public:
		///
		DataNode();		
		///
		virtual ~DataNode() {}
		
		///
		virtual bool isRenderable() {
			return false;
		}
		
		///
		virtual QString getName() const {
			return m_Name; 
		}
		
		///
		virtual void setName(QString _name) {
			m_Name = _name;
		}
		
		/// Whether the data is to be rendered. 
		virtual bool isVisible() { return m_IsVisible;}
		
		/// Change visibility of the node
		virtual void setVisible(bool visible) {
			m_IsVisible = visible;
		}
		
		/// Display function of the data
		virtual void render() {}


		/// Return a widget that display the properties of the data
		virtual QWidget* getPropertyWidget() const {
			return NULL;
		}
		/// Get the renderer for this datanode
		RenderPlugin* renderer() const {
			return m_pRenderer;
		}
		/// 
		virtual void setRenderer(RenderPlugin * pRenderer); 
		
		/// 
		virtual DataInterface* data() const {
			return NULL;
		}

		/// Update the data in the datanode
		/**
		 * @note The old data in the datanode will be deleted.
		 */
		virtual void setData(DataInterface *pData) { }

		const AxisAlignedBox& boundingBox() const {
			return m_BBox;
		}

		AxisAlignedBox& boundingBox() {
			return m_BBox;
		}

		void drawBoundingbox();

	signals:
		void dataChanged();

		void rendererChanged();

	public slots:
		void updateView();

	protected:
		QString m_Name;
		bool m_IsVisible;
		/// Renderer for the DataNode
		RenderPlugin *m_pRenderer; 

		AxisAlignedBox m_BBox;
	};
	
}
